<html>
<head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <script src="__PUBLIC__/hytn/js/jquery-1.9.1.min.js"></script>
    <title>确认交易</title>
    <style type="text/css">
    	*{margin: 0;padding: 0;font-family: "微软雅黑";}
    	
    </style>
</head>
<body style="background: #EDEDED;">
<div style="padding: 20px 0;line-height: 50px;text-align: center;">
	<div style="font-weight: 520;font-size: 18px;">三鑫订单<span id="out_trade_no">{$order_number}</span></div>
	<div style="font-size: 46px;font-weight: bold;">￥{$money}</div>
</div>
<div style="padding: 16px 0;background: #fff;">
	<span style="margin-left:5%;color: #999;">收款方</span>
	<span style="float: right;margin-right:5%;">三鑫灯世界</span>
</div>
<div align="center">
    <button style="margin-top: 20px;width:90% ;height:50px;background-color:#1AAD19; border:0px #1AAD19 solid; cursor: pointer;  color:white;  font-size:18px;font-weight: bold;" type="button" onclick="callpay()" >立即支付</button>
</div>
<div class="tiaozhuan" style="position: absolute;top:0;bottom: 0;left: 0;right: 0;background: #999;opacity: .7;display:none;">
    <div style="height: 50px;width:60%;line-height: 50px;margin:300px auto;text-align: center;background: #000;color: #fff;opacity: 1;">
        页面跳转中 <span class="numtiao">2</span>s
    </div>
</div>
<script type="text/javascript">
    //调用微信JS api 支付
    function jsApiCall()
    {
        WeixinJSBridge.invoke(
                'getBrandWCPayRequest',
                {$jsApiParameters},
                function(res){
//                WeixinJSBridge.log(res.err_msg);
//                alert(res.err_code+res.err_desc+res.err_msg);
                    if(res.err_msg == 'get_brand_wcpay_request:ok'){
                    var myInt = setInterval(check,1000);
                        function check() {
                            var out_trade_no = $('#out_trade_no').text();
                            alert(out_trade_no);
                            $.ajax({
                                type:'post',
                                url:"{:U('Pay/orderquery')}",
                                data:{'out_trade_no':out_trade_no},
                                success:function (e) {
                                    if(e == 1){
                                        clearInterval(myInt);
                                        $('.tiaozhuan').show();
                                        var datatime =2;

                                        function time(){
                                            datatime = 	datatime -1;
                                            $('.numtiao').text(datatime);
                                            var ting = setTimeout(time,1000);
                                            if(datatime <= 0){
                                                window.location.href="{:U('Index/orders_payment')}";
                                                clearTimeout(ting)
                                            }
                                            console.log(datatime)
                                        }
                                        setTimeout(time,1000)
                                    }else{
                                        return false;
                                    }
                                }
                            })
                        }
                    }
                }
        );
    }

    function callpay()
    {
        if (typeof WeixinJSBridge == "undefined"){
            if( document.addEventListener ){
                document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
            }else if (document.attachEvent){
                document.attachEvent('WeixinJSBridgeReady', jsApiCall);
                document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
            }
        }else{
            jsApiCall();
        }
    }
</script>
</body>
